<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>仓库货位设置</title>
</head>

<body>
<div style="padding: 10px;">

    <div class="panel panel-default">
        <div class="panel-heading">正在操作：<!--{if $storeShelf}-->修改货位<!--{else}-->添加货位<!--{/if}--></div>
        <div class="panel-body">
            <form class="form-horizontal" role="form" id="shelf_form" onsubmit="return false;">

                <div class="form-group">
                    <label for="storeID" class="col-sm-2 control-label">选择仓库 <font color="red">*</font></label>
                    <div class="col-sm-10">
                        <select class="form-control col-sm-2" id='storeID' name='storeID' style="width: 200px;">
                            <option value=''>请选择</option>
                            <!--{foreach from=$store_array item=value}-->
                                <option value='<!--{$value->storeID}-->'<!--{if $storeID == $value->storeID}--> selected <!--{/if}--> ><!--{$value->storeName}--></option>
                            <!--{/foreach}-->
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label for="shelf_name" class="col-sm-2 control-label">货位号 <font color="red">*</font></label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="shelf_name" id="shelf_name" style="width:200px;" value="<!--{$storeShelf->shelf_name}-->">
                        <span class="help-block red">位号规则：货区-货架号-列号-行号(例：A-1-3-1)</span>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="button" class="btn btn-primary" onclick="shelf.check();" value="保存" />&nbsp;&nbsp;
                        <input type="button" class="btn btn-warning" onclick="E.closeWindows();" value="关闭" />
                    </div>
                </div>

                <input type="hidden" name="shelfID" value="<!--{$shelfID}-->">
            </form>
        </div>
    </div>

</div>

<script type="text/javascript">

    //全局变量
    var shelfID = '<!--{$storeShelf->shelfID}-->';

    var shelf = {

        dt: "",

        check: function() {

            this.dt = E.getFormValues("shelf_form");
            var error_msg = "";

            if (this.dt.storeID == ""){
                error_msg += "仓库不能为空<br />";
            }

            if (this.dt.shelf_name == ""){
                error_msg += "货位号不能为空<br />";
            }

            if (error_msg != "")
                E.alert(error_msg);
            else {
                this.add();
            }

        },

        add: function() {
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/wms/storeShelf.ajax?operFlg=8",
                dataType: "JSON",
                data: this.dt,
                success: function( result_obj ) {
                    if (result_obj.code == 200) {

                        E.opener("storeShelf.load");

                        if( shelfID ){
                            E.alert(result_obj.message , 2 , "E.closeWindows()");
                        }else{
                            E.alert(result_obj.message , 2 , "shelf.clear");
                        }


                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        clear:function(){
            $("#shelf_name").val('');
        }


    };


</script>

</body>

</html>
